package cn.leyaber.hrm.service.impl;

import cn.leyaber.hrm.domain.Goods;
import cn.leyaber.hrm.mapper.GoodsMapper;
import cn.leyaber.hrm.redusutils.constants.CommentConstant;
import cn.leyaber.hrm.service.IGoodsService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ma.rui.kai
 * @since 2020-12-11
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService {
   @Autowired
   private  GoodsMapper goodsMapper;
    //批量删除
    @Override
    public void batchDelete(List<Long> ids) {
        System.out.println(ids);
        goodsMapper.batchDelete(ids);
    }

    /**
     * 修改状态
     * @param goods
     */
    @Override
    public void Modify_status(Goods goods) {
        if (goods.getState().equals(CommentConstant.COMMENT_DISABLE)){
            goods.setState(CommentConstant.COMMENT_ENABLE);
            goodsMapper.updateById(goods);
        }else {
            goods.setState(CommentConstant.COMMENT_ENABLE);
            goodsMapper.updateById(goods);
        }

    }
}
